#include<func.h>
struct timeval start;
void sigfunc(int signum)
{
    struct timeval end;
    gettimeofday(&end,NULL);
    printf("当前执行时间是%ld秒\n",end.tv_sec-start.tv_sec);
}
int main()
{
    signal(SIGPROF,sigfunc);
    struct itimerval t;
    bzero(&t,sizeof(t));
    t.it_value.tv_sec=3;
    t.it_interval.tv_sec=2;
    printf("当前时间是0秒\n");
    int ret=setitimer(ITIMER_PROF,&t,NULL);
    ERROR_CHECK(ret,-1,"setitimer")
    sleep(3);
    gettimeofday(&start,NULL);
    while(1);
    return 0;
}